import wepy from 'wepy'
export default class extends wepy.mixin {
    config = {

    }

    data = {
        cart: []
    }

    onLoad() {
        this.cart = this.$parent.globalData.cart
    }

    methods = {
        onChangeStepper(e) {
            // console.log(e.detail);
            // console.log(e.target.dataset.id);
            var id = e.target.dataset.id
            var count = e.detail
            this.$parent.updateCount(id, count)

        }
    }

    computed = {
        isEmpty() {
            if (this.cart.length <= 0) {
                return true
            }
            return false
        }
    }

    async getCatesData() {
        var { data: res } = await wepy.get('/categories')
        console.log(res)
        if (res.meta.status != 200) {
            return wepy.baseToast()
        }
        this.catesList = res.message
        this.secondData = this.catesList[0].children
        this.$apply()
    }

    async getWindowHeight() {
        var res = await wepy.getSystemInfo()
        console.log(res)
        if (res.errMsg == 'getSystemInfo:ok') {
            this.wh = res.windowHeight
            this.$apply()
        }


    }


}